home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / fx < prev    next >
Internet Message Format  |  1995-03-31  |  17KB

  1. From: Chris Tham <christie@extro.ucc.su.OZ.AU>
  2. Subject:  v03i005:  fx - Currency Two-way Pricing v1.0, Part01/01
  3. Newsgroups: comp.sources.hp48
  4. Followup-To: comp.sys.hp48
  5. Approved: spell@seq.uncwil.edu
  6.  
  7. Checksum: 1521524764 (verify with brik -cv)
  8. Submitted-by: Chris Tham <christie@extro.ucc.su.OZ.AU>
  9. Posting-number: Volume 3, Issue 5
  10. Archive-name: fx/part01
  11.  
  12. BEGIN_RDME fx.doc
  13. HP-48SX Foreign Currency Bid/Offer Pricing/Conversions Version 1.0
  14. Copyright (C) 1991 Chris Tham
  15.  
  16. Introduction
  17.  
  18. The HP-48SX FX Application performs bid/offer quotations, pricing, and
  19. cross currency rate calculations for use by professional Foreign
  20. Exchange market makers.  It allows the user to define a set of
  21. currencies and set two-way prices (quotes) for each currency against
  22. the reference currency (the US Dollar denoted by the three character
  23. code `USD').  Both direct and indirect methods of quoting currencies
  24. are supported by the application.  Each currency can then be priced on
  25. both the bid and offer sides against any other currency defined and the
  26. application will automatically perform the necessary cross rate
  27. calculation, taking the appropriate side of the two-way quotes.
  28.  
  29. Background
  30.  
  31. Foreign Exchange currency conversions/pricing are different from
  32. scientific unit conversions normally performed by the HP-48SX Units
  33. Application because there are two, instead of one, conversion factors
  34. associated with each currency.
  35.  
  36. In the foreign exchange market, dealers buy and sell one currency in
  37. exchange for another currency.  Basically, the price or value of money
  38. in one country is traded against money in another country.  A foreign
  39. exchange transaction always involve two currencies, one of which can be
  40. considered the currency bought or sold (the `base' or `commodity'
  41. currency) and the other currency can be considered the measure of value
  42. for effecting the transaction (the `terms' currency).
  43.  
  44. All transactions require two counterparties, each of which will both buy
  45. and sell currency.  The exchange rate is the price at which one currency
  46. can be exchange for another.  Currency names are abbreviated using
  47. standard codes developed for computer input (the United States Dollar is
  48. designated by `USD', the Australian Dollar `AUD', the Japanese Yen `JPY',
  49. the German Deutschmark `DEM', the Great Britain Pound Sterling `GBP'
  50. and so on).
  51.  
  52. For example, one counterparty may purchase 1 million AUD (value is
  53. Australian Dollars $1,000,000) against the US Dollar at an exchange rate
  54. of AUD 1 = USD 0.7800 (or, in standard market quotation, AUD/USD 0.7800).
  55. This means that the counterparty has to pay (or sell) $780,000 US
  56. Dollars for the Australian Dollars bought.  The transaction can also be
  57. viewed as the counterparty exchanging USD for AUD, paying USD 0.7800 for
  58. every AUD 1 received.  The other counterparty is performing the reverse
  59. action, exchanging AUD for USD, and receiving USD 0.7800 for every AUD 1
  60. sold.
  61.  
  62. The exchange rate between any two currencies is normally quoted as the
  63. number of terms currency units required to purchase or sell one base
  64. currency unit.  The exchange rate is expressed by the commodity currency
  65. code, followed by a slash, followed by the terms currency code and then
  66. the exchange rate in terms currency units.  In the above example, the
  67. exchange rate is quoted with AUD being the base currency and USD being
  68. the terms currency, hence AUD/USD 0.7800.  In foreign exchange trading,
  69. the commodity currency is usually the focus of trading and dealers buy
  70. and sell multiples of the commodity currency.
  71.  
  72. Instead of quoting each currency against every other currency, all
  73. currencies are normally quoted against the US Dollar.  The exchange rate
  74. between any two currency can then be determined by referencing against
  75. the exchange rate for each currency against the US Dollar.  Most
  76. currencies are quoted against the US Dollar with the US Dollar as the base
  77. (or commodity) currency.  This is also called direct quotation.  Some
  78. currencies, however, notably those belonging to the so called
  79. `Commonwealth' countries including Great Britain and Australia, are
  80. quoted with the US Dollar as the terms currency.  This method of quoting
  81. is referred to as indirect quoting.  An example of a direct quotation is
  82. USD/DEM 1.8200 (note USD is the base currency and appears on the left
  83. hand side of the slash).  An example of an indirect quotation is
  84. GBP/USD 1.6293 (USD is now the terms currency and appears on the right
  85. hand side of the slash).
  86.  
  87. There is no `standard' or `reference' exchange rate for any country
  88. against the US Dollar (except when countries fix currency exchange
  89. rates with respect to other currencies).  Instead, each dealer is free
  90. to set the exchange rate for the currency that the dealer is prepared to
  91. trade.  By convention, dealers set two exchange rates, a rate in which
  92. they are prepared to buy the commodity currency (the bid rate) and a
  93. rate in which they are prepared to sell the commodity currency (the
  94. offer rate).  This is called two-way pricing or quotation.  By convention,
  95. the bid rate is quoted before the offer rate.  Hence, a typical two-way
  96. quote for AUD would be AUD/USD 0.7800/05.  This means that the bid rate
  97. for AUD/USD is 0.7800 and the offer rate is 0.7805, i.e. the dealer is
  98. prepared to buy AUD for USD 0.7800 and sell AUD for USD 0.7805.  The
  99. difference between the offer and bid quotes, i.e. USD 0.0005 or
  100. 5 `points', is called the `spread' and represents the dealer's profit
  101. from buying and selling the commodity currency.
  102.  
  103. How to use the FX application
  104.  
  105. The FX application is normally stored in a subdirectory on the HP-48SX
  106. called `FX'.  To use the application, simply enter the directory and
  107. either type the `GO' command or press the [VAR] menu key and then press
  108. the soft key marked [GO] (this should be the left most soft key if you
  109. have not created any variables in this directory).  The screen' soft
  110. menu labels should now change to something like the following
  111.  
  112.     [MKC] [RMC] [USD] [AUD] [DEM]
  113.  
  114. The soft keys [MKC] and [RMC] are used to define and undefine a new
  115. currency unit.  The remaining soft key labels denote currency codes.
  116. WHen you first install the application, the application comes
  117. preconfigured with three currencies, USD, AUD and DEM.  You are allowed
  118. to create or delete any currencies that you wish, including the
  119. predefined AUD and DEM currencies.  However, USD is a special currency
  120. that cannot be created or deleted at will due to its special status as
  121. the currency against which all other currencies are valued against.
  122.  
  123. Let's use the predefined currencies first.  Later, we will try creating
  124. and deleting currencies and see the effect on the soft menu.  Suppose
  125. you are a market maker dealing in both AUD and DEM and you are currently
  126. quoting
  127.  
  128.     AUD/USD 0.7790/95
  129.     USD/DEM 1.8155/60
  130.  
  131. Your bids and offers may be entered into the application by typing in a
  132. complex number with the real part equal to the bid rate and the imaginary
  133. part equal to the offer rate, then pressing [Right Shift] followed by
  134. the currency soft menu key.  In this instance, you will type in
  135.  
  136. [Left SHift] [ () ] 0.7790 [SPC] 0.7795 [ENTER] [Right Shift] [AUD]
  137. [Left SHift] [ () ] 1.8155 [SPC] 1.8160 [ENTER] [Right Shift] [DEM]
  138.  
  139. Note that the application `knows' that AUD is normally quoted in
  140. indirect terms and DEM is normally quoted in direct terms so you can
  141. just enter the quotes into the application and it will figure out which
  142. currency is the base currency and which is the terms currency.
  143.  
  144. Now if you buy AUD 15 million how much USD should you be selling?  The
  145. sign convention is positive if you are buying and negative if you are
  146. selling.  Type in the following
  147.  
  148.     15 [EEX] 6 [AUD]
  149.  
  150. and level 1 of the stack will now show something like
  151.  
  152.     15000000.0000_bAUD
  153.  
  154. My calculator is currently on FIX 4 mode.  Your calculator may show a
  155. slightly different format depending on your current numeric display
  156. mode.  Note that the amount 15,000,000 is suffixed by the string "_bAUD"
  157. indicating that the amount is in AUD and you are buying that currency
  158. and hence `bidding' for it.  To convert that amount to USD, simply press
  159. the [Left Shift] [USD] key and level 1 of the stack will change to
  160.  
  161.     -11685000.0000_oUSD
  162.  
  163. Hence, to buy AUD 15 million, you need to sell USD 11.685 million.
  164.  
  165. What if you were to sell AUD 15 million?  They following keystrokes will
  166. reveal the answer:
  167.  
  168.     15 [+/-] [EEX] 6 [AUD] [Left Shift] [USD]
  169.  
  170. The stack should show
  171.  
  172.     11692500.0000_bUSD
  173.  
  174. which means you will receive USD 11.6925 million.
  175.  
  176. Here are some more examples and their answers
  177.  
  178. 1. Buying DEM 6 million (6000000.0000_bDEM), pay
  179.     -3303964.7577_oUSD
  180.    {Keystrokes: 6 [EEX] 6 [DEM] [Left Shift] [USD]}
  181. 2. Selling AUD 7 million (-7000000.0000_oAUD), receive
  182.     9909004.0000_bDEM
  183.    {Keystrokes: 7 [+/-] [EEX] 6 [AUD] [Left Shift] [DEM]}
  184. 3. Buying USD 2 million (2000000.0000_bUSD), pay
  185.     -2565747.2739_oAUD
  186.    {Keystrokes: 2 [EEX] 6 [USD] [Left Shift] [AUD]}
  187.  
  188. To create a new currency, you need to know
  189. * the three letter currency code
  190. * bid/offer rates of that currency against the US dollar
  191. * whether the currency is normally quoted in direct or indirect form
  192.  
  193. As an example, suppose you want to create a new currency called GBP
  194. (Great Britain Pound Sterling).  You will be quoting GBP/USD 1.6930/35
  195. (i.e., indirectly).
  196.  
  197. Enter the following keystrokes:
  198.     [Right Shift] [" "] [Alpha] [Alpha] G B P [ENTER]
  199.     [Left Shift] [ () ] 1.6930 [SPC] 1.6935 [ENTER]
  200.     0 [ENTER]
  201.  
  202. The stack should show:
  203.  
  204. 3:    "GBP"
  205. 2:    (1.6930,1.6935)
  206. 1:    0.0000
  207.  
  208. Level 3 contains the three character currency code, i.e., GBP, level 2
  209. contains the quoted exchange rate of GBP against USD, level 1 is 0 for
  210. an indirect quote (and 1 for a direct quote).
  211.  
  212. Now press the [MKC] (Make Currency) soft key.  You should now notice a
  213. new softkey labelled [GBP] on the soft menu.  You can now perform
  214. currency conversions using GBP:
  215.  
  216. How much do you receive in GBP if you sell DEM 44,000?
  217. Keystrokes:
  218.     44 [+/-] [EEX] 3 [DEM] [Left Shift] [GBP]
  219. Answer:
  220.     14315.2674_bGBP
  221.  
  222. How do you create a new currency called "SFR" (Swiss Francs) to be
  223. quoted as USD/SFR 1.5520/25 (direct quotation)?
  224. Keystrokes:
  225.     [Right Shift] [" "] [Alpha] [Alpha] S F R [ENTER]
  226.     [Left Shift] [ () ] 1.5520 [SPC] 1.5525 [ENTER]
  227.     1 [ENTER]
  228.     [MKC]
  229.  
  230. To remove a currency, simply create a string containing the currency
  231. code of the currency to be removed, then press the [RMC] (Remove
  232. Currency) soft key.  For example, to remove the SFR currency just
  233. created, press
  234.     [Right Shift] [" "] [Alpha] [Alpha] S F R [ENTER] [RMC]
  235.  
  236. The soft menu should automatically reflect the removal of the currency.
  237.  
  238. Exiting the FX application
  239.  
  240. Just press any menu key.
  241.  
  242. Installing the FX application
  243.  
  244. Upload FX.ASC, FX.BIN or FX.48 into the directory where you wish
  245. to place the 'FX' directory on the HP-48SX (normally the HOME
  246. directory).
  247. END_RDME
  248.  
  249. BEGIN_ASC fx.asc
  250. %%HP: T(3)A(D)F(.);
  251. "69A20FF7FD900000003055354430ADA209C2A2C2A2070000D668B01B2130A200
  252. 02024F420D9D20E163292CF14B2A2B9DE1C2A20B000013F526C2A20B000013F5
  253. F6EF3A1DBBF176BA162BC193632B2130F5000303424F430D9D20E1632C2A2090
  254. 000722692CF176BA1C2A20700007276BA162BC1DBBF1C2A209000072F6DBBF17
  255. 6BA1C2A20700007276BA162BC193632B2130F700040343545F440D9D20E16328
  256. 4E20303424F41C432D6E201005D6E201024D6E2010F4E1632ADA209C2A2C2A20
  257. B000055354468B01B2130D6E201005AC7C192CF1EEDA1D6E201024DCC02D6E20
  258. 1005918C1DBBF1EEDA1D6E2010F4DCC02EF53293632B21307C000403494E4654
  259. 0D9D20E1632E89C1872B1DBBF1872B1E97C193632B2130930004034F4554540D
  260. 9D20E1632DBBF1599A1DBBF184E202024F4BD69193632B2130F3000303494E43
  261. 0D9D20E163284E202024F4DBBF1B1791EEDA193632B2130830003025D43430D9
  262. D20E16321C432D6E2010D4E163284E205034D454E455A59C11C432D6E2010E4E
  263. 16329C2A2D6E2010E430132D6E2010E45BCF13CE2278BF1B0BC1D6E2010D44BA
  264. C1AFE22D9D208DBF145632D6E2010E497632AA9028DBF1B21305DF22C4232D6E
  265. 2010E4387C14563284E205034D454E45597632DCC02D6E2010D484E20303424F
  266. 4EFE02EFE0284E202074F4EF532EF53293632B21306310030D4B43430D9D20E1
  267. 6321C432D6E201014D6E201024D6E201034E1632C2A20F0000B702B70222D6E2
  268. 0101476BA1C2A20310002202B702BA022276BA1D6E20101476BA1C2A20B10002
  269. 2023494E402BB02BA022276BA1D6E20101476BA1C2A20B1000220234F4554502
  270. BB02BA0276BA13CE22D6E201034AFE22D9D20C2A20F0000023494E46576BA1B2
  271. 1305DF22C2A20700002276BA1D6E20101476BA1C2A20700002276BA1C2A20D10
  272. 00343545F402BB02D702D702D776BA162BC184E205034D454E455DBBF176BA14
  273. 563284E205034D454E45597632DCC02D6E2010243CE22D6E201034AFE2284E20
  274. 403494E4655DF22D6E20101484E2040343545F447A2084E202074F4B21309DF0
  275. 284E202074F4EF53293632B2130C220040F64454D440ADA20339209991638442
  276. 180550C2A20B000055354468B01B21300400040264454D440ADA203392099925
  277. 92970660550C2A20B000055354468B01B21300400040F614554440ADA2033920
  278. 9990000000059770C2A20B000055354468B01B213004000402614554440ADA20
  279. 339209990000000009770C2A20B000055354468B01B21300400040F655354440
  280. ADA209C2A2C2A20B000055354468B01B213003000402655354440ADA209C2A2C
  281. 2A20B000055354468B01B2130030005034D454E4555047A2084E2030D4B43484
  282. E203025D43447A20C2A20B000055354447A20D9D20E1632C2A20B00005535448
  283. 4E20303494E493632B2130D9D20E1632C2A20B000055354484E204034F455459
  284. 3632B21308DBF1B2130B213047A20C2A20B000014554447A20D9D20E1632C2A2
  285. 0B000014554484E20303494E493632B2130D9D20E1632C2A20B000014554484E
  286. 204034F4554593632B2130D9D20E1632C2A20B000014554484E2040343545F49
  287. 3632B2130B2130B213047A20C2A20B00004454D447A20D9D20E1632C2A20B000
  288. 04454D484E20303494E493632B2130D9D20E1632C2A20B00004454D484E20403
  289. 4F4554593632B2130D9D20E163284E20403494E465C2A20B00004454D484E204
  290. 0343545F493632B2130B2130B2130B2130442002074F420D9D20E163284E2050
  291. 34D454E455D511293632B2130185A"
  292. END_ASC
  293.  
  294. BYTES: #A581h 1299
  295.  
  296. BEGIN_UU fx.uue
  297. begin 644 fx.bin
  298. M2%!(4#0X+466*O!_WPD    #55-$ ]HJD"PJ+"IP  !MA@NQ$@,J " @]"30
  299. MV0(>-I+"'[2BLMD>+"JP   Q7V(L*K   #%?;_ZCT;L?9ZMALAPY-K(2 U\ 
  300. M,# D]#30V0(>-L*B @D <"*6PA]GJ\&B @< <'*V&B;+T;L?+"J0   G;[W[
  301. M<;8:+"IP   G9ZMALAPY-K(2 W\ 0# T1?5$T-D"'C:"Y (#0T)/P332Y@(!
  302. M4&TN$"#4Y@(!3QXVHJT"R:+"H@(+ % U162X$"LQT.8" 5#*QY'"'^ZMT>8"
  303. M 4+-#-+F @%0&<C1NQ_NK='F @%/S0SB7R,Y-K(2 \< 0#"4Y&1%T-D"'C;B
  304. MF!QXLM&['WBRX7D<.3:R$@,Y $ P]%1%1=#9 AXVTKL?E:G1NQ](+B @]+1M
  305. M&3DVLA(#/P P,)3D--#9 AXV@N0" D)/O?NQ<1GNK9%C(RLQ@ ,  U)-0P.=
  306. M+>!A(\$TTN8" 4T>-H+D @5#345.55K)$4PC;2X0X.1A(\FBTN8" 4X#,=+F
  307. M @%.M?PQ["*'^[&P'&TN$-!$JQSZ+M+9 MC[064C;2X0X)1G(ZH)@KT?*S%0
  308. M_2),,M+F @%.@\=!92-(+E PU%3D5)5G(\T,TN8" 4U(+C P)/3D[R#^#H+D
  309. M @)'3_XUXE\C.3:R$@,V 3#0M#0TT-D"'C823"-M+A 0U.8" 4)M+A PY&$C
  310. M+"KP  ![('L@(FTN$!!TMAHL*C ! "(@>R"K(")GJ]'F @%!9ZO!H@(; " "
  311. M,I3D!+(+L@HB<K8:;2X0$'2V&BPJL $ (B!#3U54(+L@JR!GJS'L(FTN$#"D
  312. M[R*=+<"B @\  #*4Y&1UMAHK,5#](BPJ<   (F>KT>8" 4%GJ\&B @< ('*V
  313. M&BPJT $ 0U-43R"[('T@?2!]9ZMALAQ(+E PU%3D5-6['V>K064C2"Y0,-14
  314. MY%259R/-#-+F @%"PR[2Y@(!0_HN@N0"!$-)3E;5+]+F @%!2"Y ,#1%]42G
  315. M D@N('#TM!(#V0^"Y ("1T_^-9)C(RLQP"( !&]$14T$VBHPDP*9&39()(%0
  316. M!2PJL   55-$A@NQ$@-  $ @1E341*"M C,ID)E2*7E@!E7 H@(+ % U162X
  317. M$"LQ  0 !&]!540$VBHPDP*9"0   %!Y!RPJL   55-$A@NQ$@-  $ @%E1%
  318. M1*"M C,ID)D     D'? H@(+ % U162X$"LQ  0 !&]54T0$VBJ0+"HL*K  
  319. M %531(8+L1(#, ! (%8U142@K0+)HL*B @L 4#5%9+@0*S$  P %0TU%3E4%
  320. M="J Y (#34M#2"XP(-4T1*<"+"JP  !54T1T*M#9 AXVPJ(""P!0-46$Y (#
  321. M0TE..3:R$@.=+>!A(RPJL   55-$2"Y ,/14195C(RLQ@+T?*S&P$@-T*L"B
  322. M @L $%1%1*<"G2W@82,L*K   $%51$@N,#"4Y)1C(RLQT-D"'C;"H@(+ !!4
  323. M183D @1#3U54.3:R$@.=+>!A(RPJL   055$2"Y ,#1%]91C(RLQL!(#*S% 
  324. MIP(L*K   $1%370JT-D"'C;"H@(+ $!4U(3D @-#24XY-K(2 YTMX&$C+"JP
  325. M  !$14U(+D P]%1%E6,C*S'0V0(>-H+D @1#24Y6+"JP  !$14U(+D P-$7U
  326. IE&,C*S&P$@,K,; 2 T0"('#T)-#9 AXV@N0"!4--14Y571&28R,K,0 P
  327.  
  328. end
  329. END_UU
  330.  
  331. BEGIN_RPL fx.rpl
  332. %%HP: T(3)A(D)F(.);
  333. DIR
  334.   GO
  335.     \<< CMENU TMENU
  336.     \>>
  337.   CMENU { MKC RMC {
  338. "USD" {
  339.     \<< "USD" CIN
  340.     \>>
  341.     \<< "USD" COUT
  342.     \>> DROP } } {
  343. "AUD" {
  344.     \<< "AUD" CIN
  345.     \>>
  346.     \<< "AUD" COUT
  347.     \>>
  348.     \<< "AUD" CSTO
  349.     \>> } } { "DEM" {
  350.     \<< "DEM" CIN
  351.     \>>
  352.     \<< "DEM" COUT
  353.     \>>
  354.     \<< CINV "DEM"
  355. CSTO
  356.     \>> } } }
  357.   bUSD '1_USD'
  358.   oUSD '1_USD'
  359.   bAUD '.779_USD'
  360.   oAUD '.7795_USD'
  361.   bDEM '
  362. .550660792952_USD'
  363.   oDEM '
  364. .550812448361_USD'
  365.   MKC
  366.     \<< \-> A B C
  367.       \<< C$ 5 { { "
  368. A + C$ 7 " { \<< " +
  369. A +
  370. C$ 11 " CIN \>> \<< " +
  371. A +
  372. C$ 11 " COUT \>> \<<  +
  373.         IF C
  374.         THEN
  375. " CINV" +
  376.         END C$ 1 "
  377. + A + C$ 1 " +
  378. "CSTO \>> } } }" +
  379. STR\-> CMENU SWAP +
  380. 'CMENU' STO B
  381.         IF C
  382.         THEN CINV
  383.         END A CSTO
  384. { GO } ORDER GO
  385.       \>>
  386.     \>>
  387.   RMC
  388.     \<< \-> M
  389.       \<< CMENU LIST\->
  390. \-> N
  391.         \<< 1 N
  392.           START N
  393. ROLL
  394.             IF DUP
  395. \->STR M POS
  396.             THEN
  397. DROP 'N' DECR DROP
  398.             END
  399.           NEXT N
  400. \->LIST 'CMENU' STO M
  401. CBO PURGE PURGE GO
  402.         \>>
  403.       \>>
  404.     \>>
  405.   CIN
  406.     \<< BO SWAP UVAL
  407. *
  408.     \>>
  409.   COUT
  410.     \<< SWAP NEG SWAP
  411. BO CONVERT
  412.     \>>
  413.   CINV
  414.     \<< C\->R INV SWAP
  415. INV R\->C
  416.     \>>
  417.   CSTO
  418.     \<< CBO \-> P B O
  419.       \<< '1_USD' P
  420. RE OVER * B STO P
  421. IM SWAP * O STO
  422.       \>>
  423.     \>>
  424.   CBO
  425.     \<< "'b" OVER +
  426. "'" + STR\-> SWAP
  427. "'o" SWAP + "'" +
  428. STR\->
  429.     \>>
  430.   BO
  431.     \<< OVER 0 \>=
  432. "1_b" "1_o" IFTE
  433. SWAP + STR\->
  434.     \>>
  435.   USD '1_m'
  436. END
  437. END_RPL
  438.  
  439. christie@extro.ucc.su.oz.au
  440.